package com.hcw.library.controller;

import com.hcw.library.common.Result;
import com.hcw.library.domain.BookType;
import com.hcw.library.service.BookTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
public class BookTypeController {

    @Autowired
    private BookTypeService bookTypeService;

    @PostMapping("/bookType/addBookType")
    @ResponseBody
    public Result<Integer> addBookType(@RequestBody BookType bookType){
        return bookTypeService.addBookType(bookType);
    }

    @GetMapping("/bookType/deleteBookType")
    @ResponseBody
    public Result<Integer> deleteBookType(String id){
        return bookTypeService.deleteBookType(id);
    }

    @PostMapping("/bookType/updateBookType")
    @ResponseBody
    public Result<Integer> updateBookType(@RequestBody BookType bookType){
        return bookTypeService.updateBookType(bookType);
    }

    @GetMapping("/bookType/queryBookTypeList")
    @ResponseBody
    public Result<List<BookType>> queryBookTypeList(){
        return bookTypeService.queryBookTypeList();
    }

    @GetMapping("/bookType/queryBookTypeByName")
    @ResponseBody
    public Result<Integer> queryBookTypeByName(String typeName){
        return bookTypeService.queryBookTypeByName(typeName);
    }

    @GetMapping("/bookType/queryBookTypeById")
    @ResponseBody
    public Result<BookType> queryBookTypeById(String id){
        return bookTypeService.queryBookTypeById(id);
    }

    @RequestMapping("/bookType.html")
    public String bookType(){
        return "bookType";
    }
}
